package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.rm.zeyou.entity.Technician;
import com.rm.zeyou.entity.User;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.TechnicianTimeService;
import com.rm.zeyou.util.login.LoginUtil;
import com.rm.zeyou.util.login.TechnicianLoginUtil;
import com.rm.zeyou.vo.request.UpdateTechnicianTimeVo;
import com.rm.zeyou.vo.request.UserSelectTechnicianTimeVo;
import com.rm.zeyou.vo.response.UserSelectTechnicianTimeResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 技师时间管理表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:09
 */
@Api(tags = "技师时间管理相关")
@RestController
@RequestMapping("/api/technicianTime")
public class TechnicianTimeController {
    @Resource
    private TechnicianTimeService technicianTimeService;
    @Resource
    private TechnicianLoginUtil technicianLoginUtil;
    @Resource
    private LoginUtil loginUtil;

    @ApiOperation(value = "用户查询技师时间")
    @PostMapping("userSelectTechnicianTime")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<List<UserSelectTechnicianTimeResponseVo>> userSelectTechnicianTime(@RequestBody UserSelectTechnicianTimeVo technicianTimeVo) {
        User user = loginUtil.getUser();
        return technicianTimeService.userSelectTechnicianTime(technicianTimeVo);
    }

    @ApiOperation(value = "技师查询技师时间")
    @PostMapping("technicianSelectTechnicianTime")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<List<UserSelectTechnicianTimeResponseVo>> technicianSelectTechnicianTime(@RequestBody UserSelectTechnicianTimeVo technicianTimeVo) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianTimeService.technicianSelectTechnicianTime(technician,technicianTimeVo);
    }


    @ApiOperation(value = "技师修改技师时间")
    @PostMapping("updateTechnicianTime")
    @SaCheckLogin(type = "technician")
    public ApiRestResponse<Integer> updateTechnicianTime(@RequestBody UpdateTechnicianTimeVo technicianTimeVo) {
        Technician technician = technicianLoginUtil.getTechnician();
        return technicianTimeService.updateTechnicianTime(technician,technicianTimeVo);
    }

}
